package org.jackysoft.entity;

import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.apache.struts2.json.annotations.JSON;
import org.jackysoft.entity.Department;
import org.jackysoft.entity.OfficeDocument;
import org.jackysoft.entity.User;
import org.joda.time.DateTime;

import com.google.common.collect.Lists;

/**
 * 成品日报表
 * */
@Entity
@org.hibernate.annotations.Entity(
		dynamicUpdate=true,
		dynamicInsert=true)
public class ArmDailyProductReporter 
extends AbstractReporter {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1568208468689512168L;
	private OfficeDocument research;
	private ArmDailyProductReporter last;
	private Collection<ArmItem> researchItems = Lists.newArrayList();
	
	public ArmDailyProductReporter() {
		super();
	}

	public ArmDailyProductReporter(String id, String title,
			DateTime createDate,
			DateTime updateDate, User maker, Department department) {
		super(id, title,createDate,updateDate, maker, department);		
	}

	public void setLast(ArmDailyProductReporter last) {
		this.last = last;
	}

	@ManyToOne
	public ArmDailyProductReporter getLast() {
		return last;
	}
	
	@ManyToOne(cascade=CascadeType.ALL)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL})
	public OfficeDocument getResearch() {
		return research;
	}

	public void setResearch(OfficeDocument research) {
		this.research = research;
	}

	@Override
	public ArmDailyProductReporter clone() {
		ArmDailyProductReporter r = (ArmDailyProductReporter) super.clone();		
		return r;
	}

	
	@JSON(serialize=false)
	@Transient
	public Collection<ArmItem> getResearchItems() {
		return researchItems;
	}

	public void setResearchItems(Collection<ArmItem> researchItems) {
		this.researchItems = researchItems;
	}
	
	

}
